﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SystemCore.Helper
{
    public static class ExceptionHelper
    {
        
        public static void Log(string logMessage)
        {
            if (!string.IsNullOrEmpty(logMessage.Trim()))
            {
                var logFilePath = File.AppendText("c:\\export\\log.txt");
                logFilePath.AutoFlush = true;
                logFilePath.Write("\r\nLog Entry : ");
                logFilePath.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
                    DateTime.Now.ToLongDateString());
                logFilePath.WriteLine("  :{0}", logMessage);
                logFilePath.WriteLine("-------------------------------");
                logFilePath.Close();
            }
        }

        public static void LogAppError(string logMessage)
        {
            if (!string.IsNullOrEmpty(logMessage.Trim()))
            {
                var logFilePath = File.AppendText("c:\\export\\logApp.txt");
                logFilePath.AutoFlush = true;
                logFilePath.Write("\r\nLog Entry : ");
                logFilePath.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
                    DateTime.Now.ToLongDateString());
                logFilePath.WriteLine("  :{0}", logMessage);
                logFilePath.WriteLine("-------------------------------");
                logFilePath.Close();
            }
        }
        public static void DumpLog(StreamReader r)
        {
            string line;
            while ((line = r.ReadLine()) != null)
            {
                Console.WriteLine(line);
            }
        }
    }
}
